package com.dddpeter.yater;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import java.util.ArrayList;
import java.util.Iterator;

public class DrawView extends View {
	static public  ArrayList circleArray=new ArrayList();
	static boolean draw=false;
	
	private Runnable runnable = new Runnable() {
	    public void run() {
	        while( true )
	        {
	            try {

	            	if(draw){
	                postInvalidate();
	            	}
	            	}
	            catch (Exception e) {
	                e.printStackTrace();
	            }
	        }
	    }
	};

	@Override
	protected void onDraw(Canvas canvas) {
		
		super.onDraw(canvas);
		Paint p=new Paint();
		Iterator it=this.circleArray.iterator();
		
		while(it.hasNext()){
			Circle c=(Circle) it.next();
			p.setColor(c.getColor());
			canvas.drawCircle(c.getmX(), c.getmY(), c.getRadius(), p);
		}
		
	}


	public DrawView(Context context, AttributeSet attrs) {
		super(context, attrs);
		Thread thread=new Thread(runnable);
		thread.start();
	}

}
